﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Homework05
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Random ran = new Random();
            int pc = ran.Next(0,3);
            int ren = 4;
            if(radioButton1.Checked)
            {
                ren = 0;
            }
            else if(radioButton2.Checked) 
            {
                ren = 1;            
            }
            else 
            {
                ren = 2;
            }
            switch (pc) 
            {
                case 0:
                    this.lb2.Text = "石头";
                    break;
                case 1:
                    this.lb2.Text = "剪刀";
                    break;
                case 2:
                    this.lb2.Text = "布";
                    break;
            }
            if ((pc == 0 && ren == 0) || (pc == 1 && ren == 1) || (pc == 2 && ren == 2)) 
            {
                this.lb3.Text = "平局";
                MessageBox.Show("平局");
            }
            else if ((pc == 0 && ren == 1) || (pc == 1 && ren == 2) || (pc == 2 && ren == 0))
            {
                this.lb3.Text = "你赢了";
                MessageBox.Show("电脑赢");            
            }
            else if ((pc == 0 &&ren == 2) || (pc == 1 && ren == 0) || (pc == 2 && ren == 1)) 
            {
                this.lb3.Text = "你输了";
                MessageBox.Show("我赢了");              
            }
        }
    }
}
